/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.awt.Component;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
import model.Artist;

/**
 *
 * @author sky
 */
public class ArtistSelectBoxRenderer extends DefaultListCellRenderer {
    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    if (value instanceof Artist) {
        Artist a = (Artist)value;
        //pat3group: sky - Συνθέτω το ονοματεπώνυμο - ψευδώνυμο καλλιτέχνη
        String str="";
            try {
                str = (a.getArtistArtname().length()==0)?"":", ("+a.getArtistArtname()+")";
            } catch (Exception e) {
                System.out.println("Artist Artname null");
            }
            try {
                setText(a.getArtistLname()+" "+a.getArtistFname()+str);
            } catch (Exception e) {
                System.out.println("artist string error");
            }
    }
        return this;
    }
    
}
